package com.leo;

import javafx.application.Application;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.effect.ColorAdjust;
import javafx.scene.effect.Effect;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Paint;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
 * @ClassName BoxBlurDemo
 * @Description
 * @Author wangss
 * @date 2020.07.01 21:15
 * @Version 1.0
 */
public class ColorAdjustDemo extends Application {

    public static void main(String[] args) {
        launch(args);
    }

    @Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane an = new AnchorPane();

        HBox hBox = new HBox(200);
        hBox.setAlignment(Pos.CENTER);

        Button button = new Button("button");

        Text text = new Text("this is Text 你好");

        Rectangle rec = new Rectangle(100, 100, Paint.valueOf("#3238b0"));

        Circle circle = new Circle(50, Paint.valueOf("#FF69B4"));

        hBox.getChildren().addAll(button, text, rec, circle);

        hBox.getChildren().forEach(node -> node.setEffect(createEffect()));

        an.getChildren().add(hBox);
        AnchorPane.setTopAnchor(hBox, 50d);
        AnchorPane.setLeftAnchor(hBox, 50d);

        Scene scene = new Scene(an);
        primaryStage.setScene(scene);
        primaryStage.setHeight(1000d);
        primaryStage.setWidth(1500d);
        primaryStage.setAlwaysOnTop(true);
        primaryStage.show();
    }

    private Effect createEffect() {

        ColorAdjust effect = new ColorAdjust();
        effect.setHue(0.5);

        return effect;
    }
}
